package com.yxym.string_;

public class StringExercise01 {
    public static void main(String[] args) {
        String a = "abc";
        String b = "abc";
//        System.out.println(a.equals(b));//T
//        System.out.println(a==b);//T
        String c = "yxym";
        String d = new String("yxym");
//        System.out.println(c.equals(d));//T
//        System.out.println(c==d);//F
//        System.out.println(c==d.intern());//T
//        System.out.println(d==d.intern());//F
//        String s1 = "f";
//        s1 = "ff";
//        System.out.println(s1);//s1指向两个地址，创建了两个对象
        String n = "hello" + "haha";
//        System.out.println(n);//编译器优化，创建一个对象
        String e = "hello";
        String f = "abc";
        String g = e + f;//创建三个对象
//        System.out.println(e);
//        System.out.println(f);
//        System.out.println(g);
        String s1 = "yxym";
        String s2 = "java";
        String s3 = "yxymjava";
        String s4 = (s1 + s2).intern();
        System.out.println(s3==s4);
        System.out.println(s3.equals(s4));;
    }
}
